ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾VBScript£¾VBScript


objects constants operators statements functions properties methods






FUNCTION:  Array( )

Array(List)

The Array function is used to create a one-dimension array.

Note that the first element in an array is labeled zero, for example,
myarray(0).

The List argument is a listing of values that will become the elements of the array.

Code:
<% myarray = array("A", "B", "C", "D") %>
<% =myarray(0) %>
<% =myarray(1) %>
<% =myarray(2) %>
<% =myarray(3) %>

Output:
A
B
C
D

Code:
<% myarray = array(111, 222, 333, 444, 555) %>
<% =myarray(0) %>
<% =myarray(1) %>
<% =myarray(2) %>
<% =myarray(3) %>
<% =myarray(4) %>

Output:
111
222
333
444
555

If you wish to create a multiple-dimension array, you need to declare it using the Dim statement. The example creates an array that has four dimensions and each dimension will contain eleven elements which will be numbered: 0 1 2 3 4 5 6 7 8 9 10.

The number of dimensions that you can create is limited by the available memory. If you exceed the available memory while declaring an array, you will get an error message.

Code:
<% Dim twoarray(10, 10, 10, 10) %>